****************************************************************************************************************
**																											  **
** This do file is part of the replication material for the following article: 								  **
**  "Voter mobilization in the echo chamber: Broadbandinternet and the rise of populism in Europe" 	          **
** 		Authors: Max Schaub, Davide Morisi			    													  **
** 		Journal: European Journal of Political Research														  **
**																											  **
** This file replicates the following step of the analysis: 												  **
**																											  **
**		RECODING MERGED GERMANY DATASET																		  **
**		Note: The steps below have to be conducted on the premises of the GESIS Secure Data Centre Cologne    **																											  **
**            The following link expalins how to access the data:                                             **
**            https://www.gesis.org/en/services/data-analysis/more-data-to-analyze/secure-data-center-sdc.    **
**																											  **
****************************************************************************************************************

*Set working directory
cd "..."

ssc install fre

use MV_SA_BW_RP_SH_combined_incl_plz.dta

**************************
*RECODING 


//// Core dependent and independent variables
* Vote intent
clonevar voteintent = l9ba
recode voteintent 206=800 801=800
clonevar voteintent_afd = voteintent
recode voteintent_afd 1=0 4=0 5=0 6=0 7=0 800=0 215=0 322=1
label variable voteintent_afd "Would vote for AfD vs. others in BW"
* Self-reported internet use for political purposes
clonevar int_pol_use = l67
gen int_pol_use1 = (int_pol_use-1)/7
label variable int_pol_use1 "Internet political use"

//// Demographics
gen age = 2016-l2
clonevar sex = l1
label variable sex Female
clonevar edu = l3
recode edu 9=6
gen edu_cat3_rev = edu
recode edu_cat3_rev (1 2 3 4 5 = 3) (6 7 = 2) (7 8 = 1)
label define edu_cat3_rev 1 "Higher edu" 2 "Medium edu" 3 "Lower edu"
label values edu_cat3_rev edu_cat3_rev
egen age_cat3 = cut(age), at(18 30 60 88) label
clonevar class = l196
gen class_cat3 = class
recode class_cat3 (1 2 3 = 1) (4 = 2) (5 6 = 3)
label define class_cat3 1 "Lower class" 2 "Middle class" 3 "Upper-middle class", replace
label values class_cat3 class_cat3
clonevar lrscale = l165
gen lrscale1=(lrscale-1)/10
label variable lrscale1 "Left-right scale"
gen polint1=(((polint-1)-4)*-1)/4
label variable polint1 "Political interest"
recode l181 (1 2 3 8 9 = 1) (4 5 9 = 2) (6 7 = 3) (10 = 4) (11 12 = 5), gen(employstat)
label define employstat 1 "Employed" 2 "In education" 3 "Unemployed" 4 "Pensioner" 5 "Housework"
label values employstat employstat
label variable employstat "Employment status"
recode l181 (1 2 3 8 9 = 1) (4 5 6 7 10 11 12 = 0) , gen(employed)
label variable employed "Employed"
clonevar job_en = l186
label define job_en 1 "Worker" 2 "Employee" 3 "Public servant" 5 "Self-employed" 9 "Employed other", replace
label variable job job_en
clonevar job_en_ex = job_en
replace job_en_ex = 9 if employed==0

//// Additional variables
recode lrscale (1 2 3 4=1) (5 6=2) (7 8 9 10 11=3), gen(lr3cat)
label variable lr3cat "Left-right categories"
gen age1010 = age10/10
label variable age1010 "age10"
recode l200 (1 2 3 4 5 6 = 1) (7 8 9 = 2) (10 11 12 13 = 3), gen(income3cat)
label define income3cat 1 " under 2,000 EUR/month" 2 "2,000-4,000 EUR/month" 3 "over 4,000 EUR/month", replace
label values income3cat income3cat
label variable income3cat "Income categories"
recode l5 (1 2 = 3) (3 = 2) (4 5 = 1), gen(polint_3cat)
label define polint3cat 1 "Low" 2 "Middle" 3 "High"
label values polint_3cat polint3cat
label variable polint_3cat "Political interest, categorical"
clonevar newspaper_read = l35l
gen voted2013 = l30
recode voted2013 2=0
label variable voted2013 "Turnout 2013"
label define voted2013 1 "Voted 2013" 0 "Not voted 2013"
label values voted2013 voted2013

//// Rescaling and labeling of zip-code level variables
sum popdens02 
gen popdens021 = popdens02/r(max)
label variable popdens021 "Population density"
sum slope1 
gen slope11 = slope1/r(max)
label variable slope11 "slope1"
label variable popdens02 "Population density"
label variable degrees_univ08 "Share with univ degrees"
label variable unempl01 "Unemployment"
label variable over65_01 "Share over 65 years"
label variable mbits61 "Broadband coverage"
